home *** CD-ROM | disk | FTP | other *** search
- #include <owl\applicat.h>
- #include <owl\window.h>
- #include <owl\slider.h>
- #include "dowlsldr.h"
- #include <stdio.h>
- #include <dos.h>
- #include <windows.h>
- #if !defined(__FLAT__)
- #pragma options -xc -WD
- #endif
-
- const WORD ID_THERMOSTAT = 201;
-
- class MessageSink
- {
- protected:
- TOWLDelphiControl* surrogate;
-
- public:
- MessageSink()
- {
- surrogate = new TOWLSlider;
- }
- TOWLDelphiControl* GetCOMControl(){return surrogate;};
- void AddOWLClass(TWindow *Window)
- {
- if (surrogate != NULL)
- surrogate->InsertOWLControl(Window);
- };
- void Dispatcher(UINT Msg, WPARAM wp, LPARAM lp )
- {
- if (surrogate != NULL)
- surrogate->DoDispatch(Msg, wp, lp);
- };
-
- };
-
- class TDHSLider : public THSlider, public MessageSink {
-
- public:
- TDHSLider(TWindow* parent,
- int id,
- int X, int Y, int W, int H,
- TResId thumbResId,
- TModule* module = 0):
- THSlider(parent,id,X,Y,W,H,thumbResId, module),
- MessageSink()
- {
- AddOWLClass(this);
- };
-
- protected:
- void DoChange()
- {
- if (surrogate != NULL)
- ((TOWLSlider *)surrogate)->DoChange();
- }
- virtual void SetPosition(int thumbPos)
- {
- THSlider::SetPosition(thumbPos);
- DoChange();
- }
-
- virtual LRESULT Dispatch(TEventInfo& info, WPARAM wp, LPARAM lp = 0)
- {
- Dispatcher(info.Msg,wp,lp);
- return TEventHandler::Dispatch(info,wp,lp);
- };
- };
-
-
- class Tracker
- {
- TWindow *CondemnedWindows;
- void AddToCondemnedList(TWindow* win)
- {
- win->SetNext(CondemnedWindows);
- CondemnedWindows = win;
- }
-
- public :
- Tracker(){CondemnedWindows = NULL;};
- ~Tracker()
- {
- //Delete all parent aliases and release all thunks
- while (CondemnedWindows)
- {
- TWindow* next = CondemnedWindows->Next();
- delete CondemnedWindows;
- CondemnedWindows = next;
- }
- }
-
- TWindow *AddParentAlias(HWND far parentHWnd)
- {
- TWindow *aNewParent = GetWindowPtr(parentHWnd);
- //Check if we have a already created to use parent
- if (aNewParent == NULL)
- {
- aNewParent = new TWindow(parentHWnd,::Module);
- AddToCondemnedList(aNewParent);
- }
- return aNewParent;
- }
- };
-
-
-
-
- //>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<
- static Tracker *TrackSliders;
-
- extern "C" {
- TOWLDelphiControl * _export _cdecl
- COMCLASSCONSTRUCTOR(HWND far parentHWnd)
- {
- TDHSLider *OwlControl = NULL;
- TWindow *aParent =
- TrackSliders->AddParentAlias(parentHWnd);
-
- if (aParent != NULL)
- {
- TDHSLider *OwlControl =
- new TDHSLider(
- aParent,
- ID_THERMOSTAT,
- 0, 0, 240, 40,
- IDB_HSLIDERTHUMB ,
- ::Module);
-
- if (OwlControl != NULL)
- return OwlControl->GetCOMControl();
- }
- return NULL;
- }
-
- void _export _cdecl COMCLASSDESTRUCTOR( TOWLDelphiControl *aControl)
- {
- if (aControl != NULL)
- delete aControl;
- }
-
- }
-
- int
- OwlMain(int /*argc*/, char* /*argv*/ [])
- {
- TrackSliders = new Tracker;
- return 0;
- }
-
- #pragma argsused
-
- int FAR PASCAL WEP (int bSystemExit)
- {
- delete TrackSliders;
- return 1;
- }
-
-
-